package com.wyzz.hr.action;

import com.wyzz.hr.base.DWRUtil;
import com.wyzz.hr.bo.ILeavebalanceBO;
import com.wyzz.hr.pojo.Leavebalance;
import com.wyzz.hr.spring.SpringBeanFactory;

public class LeaveBalanceDWR {

	public LeaveBalanceDWR() {
	}

	public Leavebalance getLeavebalanceById(String id) {
		if ("error".equals(DWRUtil.checkAuth("initLeaveBalance",
				"initLeaveBalance")))
			return null;
		ILeavebalanceBO leaveBalanceBo = (ILeavebalanceBO) SpringBeanFactory
				.getBean("leavebalanceBO");
		Leavebalance lb = leaveBalanceBo.getLeaveBalanceById(id);
		if (lb == null) {
			return null;
		} else {
			lb.setLbEmpNo(null);
			return lb;
		}
	}

	public String deleteLeaveBalanceById(String id) {
		if ("error".equals(DWRUtil.checkAuth("initLeaveBalance",
				"initLeaveBalance"))) {
			return "\u65E0\u6743\u64CD\u4F5C!";
		} else {
			ILeavebalanceBO leaveBalanceBo = (ILeavebalanceBO) SpringBeanFactory
					.getBean("leavebalanceBO");
			leaveBalanceBo.deleteLeaveBalance(id);
			return null;
		}
	}

	public String updateLeaveBalance(Leavebalance leaveBalance) {
		if ("error".equals(DWRUtil.checkAuth("initLeaveBalance",
				"initLeaveBalance")))
			return "\u65E0\u6743\u64CD\u4F5C!";
		ILeavebalanceBO leaveBalanceBo = (ILeavebalanceBO) SpringBeanFactory
				.getBean("leavebalanceBO");
		Leavebalance old = leaveBalanceBo.getLeaveBalanceById(leaveBalance
				.getLbId());
		if (old == null) {
			return "\u8981\u66F4\u65B0\u7684\u6570\u636E\u4E0D\u5B58\u5728\u6216\u5DF2\u7ECF\u88AB\u5220\u9664!";
		} else {
			old.setLbBalForwardDay(leaveBalance.getLbBalForwardDay());
			old.setLbBalForwardHour(leaveBalance.getLbBalForwardHour());
			old.setLbBalEndDate(leaveBalance.getLbBalEndDate());
			old.setLbComments(leaveBalance.getLbComments());
			old.setLbDaysOfYear(leaveBalance.getLbDaysOfYear());
			old.setLbDaysForRelease(leaveBalance.getLbDaysForRelease());
			old.setLbHoursForRelease(leaveBalance.getLbHoursForRelease());
			old.setLbReleaseStartDate(leaveBalance.getLbReleaseStartDate());
			old.setLbHoursOfYear(leaveBalance.getLbHoursOfYear());
			old.setLbOtherDays(leaveBalance.getLbOtherDays());
			old.setLbOtherHours(leaveBalance.getLbOtherHours());
			leaveBalanceBo.updateLeaveBalance(old);
			return null;
		}
	}
}
